﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using ABCTile.Models;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace ABCTile.DAL
{
    public class ABCDbContext : DbContext
    {
        public DbSet<User> Users { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Tile> Tiles { get; set; }
        public DbSet<Manufacture> Manufactures { get; set; }
        public DbSet<Color> Colors { get; set; }
        public DbSet<Shape> Shapes { get; set; }
        public DbSet<Test> Tests { get; set; }
        public DbSet<Project> Projects { get; set; }
        public DbSet<Vendor> Vendors { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

            modelBuilder.Entity<Manufacture>()
                .HasMany(c => c.Vendors)
                .WithMany(i => i.Manufactures)
                .Map(t => t.MapLeftKey("ManufactureID")
                .MapRightKey("VendorID")
                .ToTable("ManufactureVendor"));
        }
    }

}